<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    <div class="container-div">
    	<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="user-form">
					<input type="hidden" id="deptId" name="deptId">
	                <input type="hidden" id="parentId" name="parentId">
					<div class="select-list">
						<ul>
							<li>
								问题：<input type="text" name="title"/>
							</li>
							<li class="select-time">
								<label>提问时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()" shiro:hasPermission="system:user:export"><i class="fa fa-download"></i>&nbsp;导出</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
	        	<a class="btn btn-primary" onclick="$.operate.add()" shiro:hasPermission="system:user:add">
	                <i class="fa fa-plus"></i> 添加
	            </a>
	            <a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:problem:remove">
	                <i class="fa fa-remove"></i> 删除
	            </a>
	        </div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
    </div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('module:problem:edit')}]];
        var removeFlag = [[${@permission.hasPermi('module:problem:remove')}]];
        var datas = [[${@dict.getType('knowledge_label')}]];
        var prefix = ctx + "module/problem";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "问题管理",
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '编号',
		            visible: false
				},
				{
					field : 'title', 
					title : '问题' 
				},
				{
					field : 'content', 
					title : '问题内容' 
				},
				{
					field : 'userId', 
					title : '提问者ID' ,
		            visible: false
				},
				{
					field : 'dictLabel', 
					title : '标签' ,
		            formatter: function(value, row, index) {
		            	return $.table.selectDictLabel(datas, value);
		            }
				},
				{
					field : 'createBy', 
					title : '提问者' 
				},
				{
					field : 'createTime', 
					title : '创建时间' 
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
		            	actions.push('<a class="btn btn-info btn-xs  href="#" onclick="detail(\'' + row.id + '\')"><i class="fa fa-list-ul"></i>回答列表</a> ');
		            	actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        
        /*回答列表-详细*/
		function detail(id) {
		    var url = prefix + '/detail/' + id;
		    createMenuItem(url, "问题回答");
		}
    </script>
</body>
</html>